int servoPin = 8;     // Control pin for servo motor
float servoPos = 1.5;

int refreshTime = 20; // the time needed in between pulses

int analogValue = 0;  // the value returned from the analog sensor
int analogPin = 0;    // the analog pin that the sensor's on

int printTime=500;
float lastPrint=0;


void setup() {
  pinMode(servoPin, OUTPUT);  // Set servo pin as an output pin
  Serial.begin(9600);
  Serial.println("Servo Control 1.0");
}

void loop() {
  analogValue = analogRead(analogPin);      // read the analog input
  servoPos = (int)(analogValue/1024)+1;
  //pulse = (((float)analogValue / (float)1023)*maxPulse) + minPulse; 

    digitalWrite(servoPin, HIGH);   // Turn the motor on
    delayMicroseconds((int)servoPos);       // Length of the pulse sets the motor position
    digitalWrite(servoPin, LOW);    // Turn the motor off
    delay(refreshTime);
    
    /*if (millis() - lastPrint >printTime){
      Serial.println((int)servoPos + "; " + (int)analogValue);
      lastPrint=millis();
      }*/
}
